package com.atguigu.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;

public class DLXListener implements ChannelAwareMessageListener {
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        System.out.println(new String(message.getBody()));


        try {
            long deliveryTag = message.getMessageProperties().getDeliveryTag();
            channel.basicNack(deliveryTag,true,false);
        } catch (Exception e) {
            e.printStackTrace();
            //deliveryTag 表示队列中数据的顺序(唯一表示)   true：支持多条数据   true:多天被拒收的数据返回到队列中
            //channel.basicNack(deliveryTag,true,true);
        }
    }
    }

